package cn.iocoder.yudao.module.system.convert.merchant;

import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.controller.admin.merchant.vo.MerchantApplicationPageRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.merchant.SystemMerchantAuth;
import cn.iocoder.yudao.module.system.enums.merchant.CertificationEnum;
import cn.iocoder.yudao.module.system.enums.merchant.MerchantIdentity;
import org.apache.ibatis.annotations.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author 梁富贵
 * @Date 2024/10/18
 **/

public class MerchantApplicationRespConvert {


    public List<MerchantApplicationPageRespVO> convertList(List<SystemMerchantAuth> list) {
        List<MerchantApplicationPageRespVO> lists = BeanUtils.toBean(list, MerchantApplicationPageRespVO.class);
        lists.forEach(item->{
            int index = lists.indexOf(item);
            String businessLicenses = list.get(index).getBusinessLicense();
            if(businessLicenses != null && !businessLicenses.isEmpty()){
                item.setBusinessLicenses(list.get(index).getBusinessLicense().split(","));
            }
            item.setCertificationStatus(CertificationEnum.getName(list.get(index).getCertificationStatus()));
            item.setIdentify(MerchantIdentity.getName(list.get(index).getIdentify()));
        });
        return lists;
    }
}
